
#pragma once
#include <d3dx9.h>
#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE)
#define QuadSize 30.0f

#define NUM_TRIANGLES_IN_QUAD 2
#define FIRST_COLOR  0x66666666
#define SECOND_COLOR 0x00008800

#define WALKABLE 1
#define NOT_WALKABLE 0


struct MapTile
{
int Flag; // open, closed list
int G;
int H;
int F;
int IndexInBinaryHeap;
int ParrentIndex;
int TilePosX;
int TilePosY;
int Walkable;
MapTile * NextNotWalkable;
MapTile():Walkable(WALKABLE), Flag(0), NextNotWalkable(NULL){}
//int Index;
};

class cMap
{
private:
	LPDIRECT3DVERTEXBUFFER9 g_pVB;
	int QuadsOnScreenX;
	int QuadsOnScreenY;
	D3DXVECTOR3 StartPos;
	MapTile * MapTiles;
	MapTile * FirstNotWalkable;
	MapTile * LastNotWalkable;
	int NumNotWalkableTiles;
public:
	D3DXVECTOR3 GetStartPos(){ return  StartPos; }
	int GetQuadsOnScreenX(){ return QuadsOnScreenX; }
	int GetQuadsOnScreenY(){ return QuadsOnScreenY; }
	int GetNumQuadsOnScreen(){ return QuadsOnScreenX*QuadsOnScreenY; }
	MapTile * GetMap() { return MapTiles; }
	cMap();
	~cMap();
	void Restart();
	void Render();
	void RenderNotWalkable();
	void SetTileNotWalkable(int id);
	bool GetTileIsWalkable(int id);
};